package com.java.mybatis.service.impl;

import com.java.mybatis.dao.GoodsDao;
import com.java.mybatis.entity.*;
import com.java.mybatis.service.GoodsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Goods)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 17:10:28
 */
@Service("goodsService")
public class GoodsServiceImpl implements GoodsService {
    @Resource
    private GoodsDao goodsDao;

    /**
     * 查询总数量
     * @return
     * @throws Exception
     */
    @Override
    public int queryNumber() throws Exception {
        int i = goodsDao.queryNumber();
        return i;
    }

    @Override
    public int queryCount() throws Exception {
        int i = goodsDao.queryCount();
        return i;
    }


    /**
     * 根据姓名分页查询总行数
     * @param name
     * @return
     * @throws Exception
     */
    @Override
    public int queryNumberName(String name) throws Exception {
        int i = goodsDao.queryNumberName(name);
        return i;
    }

    /**
     * 分页模糊查询库存管理
     * @return
     */
    @Override
    public List<Goods> querySelPageLike(String name, Integer page, Integer pageSize) throws Exception {
        List<Goods> goodsList = goodsDao.querySelPageLike(name, page, pageSize);
        return goodsList;
    }


    /**
     * 分页查询库存管理
     */
    @Override
    public List<Goods> querySelPage( Integer page, Integer pageSize) throws Exception {
        List<Goods> goods1 = goodsDao.querySelPage(page, pageSize);
        return goods1;
    }


    /**
     * 模糊查询库存管理
     */
    @Override
    public List<Goods> querySelKcLike(String goodsName) throws Exception {
        List<Goods> goods = goodsDao.querySelKcLike(goodsName);
        return goods;
    }

    /**
     * 模糊查询盘点管理
     */
    @Override
    public List<Goods> querySelInfo(String goodsName) throws Exception {
        List<Goods> goodsList = goodsDao.querySelInfo(goodsName);
        return goodsList;
    }

    /**
     * 分页查询盘点管理
     */
    @Override
    public List<Goods> querySelPageInfo(Integer page, Integer pageSize) throws Exception {
        List<Goods> goodsList = goodsDao.querySelPageInfo(page, pageSize);
        return goodsList;
    }

    /**
     * 通过ID查询单条数据
     *
     * @param goodsId 主键
     * @return 实例对象
     */
    @Override
    public Goods queryById(Integer goodsId) {
        return this.goodsDao.queryById(goodsId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Goods> queryAllByLimit(int offset, int limit) {
        return this.goodsDao.queryAllByLimit(offset, limit);
    }

    @Override
    public Integer selGoodsTypeCount(Integer id) throws Exception {
        return this.goodsDao.selGoodsTypeCount(id);
    }

    @Override
    public Integer selCount(Integer id) throws Exception {
        return this.goodsDao.selCount(id);
    }

    @Override
    public int insertGoods(String bianhao, String goodsname, String goodsnumber, String username, String goodsweight, String userphoen, String useraddress , Integer orderId, Integer goodsTypeID, Integer locationID, Integer goodsState, Integer goodsCode, Integer putinlocationid) throws Exception {
        return this.goodsDao.insertGoods(bianhao,goodsname,goodsnumber,username,goodsweight,userphoen,useraddress,orderId,goodsTypeID,locationID,goodsState,goodsCode,putinlocationid);
    }

    /**
     * 新增数据
     *
     * @param goods 实例对象
     * @return 实例对象
     */
    @Override
    public Goods insert(Goods goods) {
        this.goodsDao.insert(goods);
        return goods;
    }

    /**
     * 修改数据
     *
     * @param goods 实例对象
     * @return 实例对象
     */
    @Override
    public Goods update(Goods goods) {
        this.goodsDao.update(goods);
        return this.queryById(goods.getGoodsId());
    }

    /**
     * 通过主键删除数据
     *
     * @param goodsId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer goodsId) {
        return this.goodsDao.deleteById(goodsId) > 0;
    }

    /**
     * 分页查询货物信息为已入库的
     * @param state  货物状态
     * @param page   分页开始
     * @param size   分页结束
     * @return
     */
    @Override
    public List<Goods> queryStateLimit(Integer state,Integer page,Integer size){
        return goodsDao.queryStateLimit(state,page,size);
    }

    /**
     * 根据货物id修改货物状态
     * @param state
     * @param goodId
     * @return
     */
    @Override
    public int updateState(Integer state,Integer goodId){
        return goodsDao.updateState(state, goodId);
    }

    /**
     * 出库
     * @param state
     * @param goodId
     * @return
     */
    @Override
    public int updateStateDelivery(Integer state,Integer goodId){
        return goodsDao.updateStateDelivery(state, goodId);
    }

    /**
     * 根据货物状态查询总条数
     * @param state
     * @return
     */
    @Override
    public int goodStateCount(Integer state){
        return goodsDao.goodStateCount(state);
    }

    /**
     * 查询货物总行数
     * @return
     * @throws Exception
     */
    @Override
    public Integer selGoodsCount() throws Exception {
        return this.goodsDao.selGoodsCount();
    }

    @Override
    public int selGoodsAreaCount(String area) throws Exception {
        return this.goodsDao.selGoodsAreaCount(area);
    }

    @Override
    public List<Goods> selGoodsUserName(String name, Integer page, Integer size) throws Exception {
        return this.goodsDao.selGoodsUserName(name,page,size);
    }

    @Override
    public int selGoodsNameCount(String name) throws Exception {
        return this.goodsDao.selGoodsNameCount(name);
    }

    @Override
    public List<Goods> queryGoodsName() {
        return goodsDao.queryGoodsName();
    }

    @Override
    public List<Goods> selGoodsArea(String area,Integer page,Integer size) throws Exception {
        return this.goodsDao.selGoodsArea(area,page,size);
    }

    /**
     * 查询货物类别
     * @return
     * @throws Exception
     */
    @Override
    public List<Goods> selGoodsTyep() throws Exception {
        return this.goodsDao.selGoodsTyep();
    }

    @Override
    public Integer selGoodsLikeCount(String name) throws Exception {
        return this.goodsDao.selGoodsLikeCount(name);
    }

    @Override
    public List<Goods> selGoodsLike(String name,Integer page,Integer size) throws Exception {
        return this.goodsDao.selGoodsLike(name,page,size);
    }

    /**
     * 查询所有货物以及状态
     * @return
     * @throws Exception
     */
    @Override
    public List<Goods> selGoodsAll(Integer page, Integer size) throws Exception {
        return this.goodsDao.selGoodsAll(page,size);
    }

    /**
     * 根据出库批号编号查询货物总数量
     * @param outboundNumber  出库批号编号
     * @return
     */
    @Override
    public int selectGoodsNumber(String outboundNumber){
        return goodsDao.selectGoodsNumber(outboundNumber);
    }

    /**
     * 下拉框查询
     * @param map  需要的参数
     * @return
     */
    @Override
    public List<Goods> queryStateSelect(Map<String,Object> map){
        return goodsDao.queryStateSelect(map);
    }

    /**
     * 模糊查询
     * @param map
     * @return
     */
    @Override
    public List<Goods> queryStateLikeGoodsOrders(Map<String,Object> map){
        return goodsDao.queryStateLikeGoodsOrders(map);
    }

    /**
     * 模糊查询2
     * @param map
     * @return
     */
    @Override
    public List<Goods> queryStateLikeGoodsName(Map<String,Object> map){
        return goodsDao.queryStateLikeGoodsName(map);
    }

    /**
     * 下拉框查询总条数
     * @param map
     * @return
     */
    @Override
    public int queryStateSelectCount(Map<String,Object> map){
        return goodsDao.queryStateSelectCount(map);
    }

    /**
     * 模糊查询总条数
     * @param map
     * @return
     */
    @Override
    public int queryStateLikeGoodsOrdersCount(Map<String,Object> map){
        return goodsDao.queryStateLikeGoodsOrdersCount(map);
    }

    /**
     * 模糊查询总条数2
     * @param map
     * @return
     */
    @Override
    public int queryStateLikeGoodsNameCount(Map<String,Object> map){
        return goodsDao.queryStateLikeGoodsNameCount(map);
    }

    /**
     * 添加
     * @param goods
     * @return
     */
    @Override
    public int addGoods(Goods goods){
        return goodsDao.addGoods(goods);
    }
}